package com.zyq.exception;

import com.zyq.enuns.BaseCodeEnum;

/**
 * @author  xiaochi
 * @date    2021/11/21 13:38
 * @desc    业务异常
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = -6429106670540534165L;
    private int code;

    private String message;

    public BusinessException() {
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BusinessException(int code, String message,Throwable cause) {
        super(message,cause);
        this.code = code;
        this.message = message;
    }

    public BusinessException(BaseCodeEnum baseCodeEnum){
        this(baseCodeEnum.getCode(), baseCodeEnum.getMessage());
    }

    public int getCode() {
        return code;
    }
}
